package itheima.com.myreflect4;

import java.lang.reflect.Field;

public class ReflectDemo1 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException {
//        method1();
//        method2();
//        method3();
        Class clazz = Class.forName("itheima.com.myreflect4.Student");
        Field[] declaredFields = clazz.getDeclaredFields();
        for (Field declaredField : declaredFields) {
            System.out.println(declaredField);
        }

    }

    private static void method3() throws ClassNotFoundException, NoSuchFieldException {
        Class clazz = Class.forName("itheima.com.myreflect4.Student");
        Field money = clazz.getDeclaredField("money");
        System.out.println(money);
    }

    private static void method2() throws ClassNotFoundException {
        Class clazz = Class.forName("itheima.com.myreflect4.Student");
        Field[] fields = clazz.getFields();
        for (Field field : fields) {
            System.out.println(field);
        }
    }

    private static void method1() throws ClassNotFoundException, NoSuchFieldException {
        Class clazz = Class.forName("itheima.com.myreflect4.Student");
        Field gender = clazz.getField("gender");
        System.out.println(gender);
    }
}
